import Vue from 'vue'
import Vuex from 'vuex'
import persistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    history:[],
    //登录信息
    token:'',
    xinxi:[]
  },
  mutations: {
    //添加
    add(state,name){
      state.history.unshift(name)
      if(state.history.length>5){
        state.history.pop()
      }
    },
    //删除
    del(state){
      state.history=[]
    },
    //登录
    login(state,token){
      state.token=token
      // state.xinxi.push(obj)
    },
    //退出
    out(state){
      state.token=''
      // state.xinxi=[]
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [persistedState()]
})
